package objectClasses;
/**
 * TCSS 360 - Project
 */
import java.awt.Color;
import java.io.Serializable;
/**
 * A class to hold all of the information to represent a draft.
 *  
 *  @author Abraham Santini
 */
public class Draft implements Serializable{

	private final int SIZE = 32;
	private final int HARNESSES = 4;
	private final int PEDALS = 6;

	private int[] my_treadling;
	private Color[] my_treadling_color;
	private int[] my_threading;
	private Color[] my_threading_color;
	private boolean[][] my_tieup;


	public Draft() {
		my_treadling = new int[SIZE];
		my_treadling_color = new Color[SIZE];
		// sets the default weft thread color to white.
		for(int i = 0; i < SIZE; i++) {
			my_treadling_color[i] = Color.WHITE;
		}
		my_threading = new int[SIZE];
		my_threading_color = new Color[SIZE];
		// sets the default warp thread color to black
		for(int i = 0; i < SIZE; i++)
			my_threading_color[i] = Color.black;

		my_tieup = new boolean[HARNESSES][PEDALS];
	}
	/**
	 * Returns the Treadling Array.
	 * @return my_treadling
	 */
	public int[] getTreadlingArray() {
		return my_treadling;
	}
	/**
	 * Returns the array that hold the Treadling Colors.
	 * @return my_treadling_color;
	 */
	public Color[] getTreadlingColorArray() {
		return my_treadling_color;
	}
	/**
	 * Return the Threading array.
	 * @return my_threading
	 */
	public int[] getThreadingArray() {
		return my_threading;
	}
	/**
	 * Returns the array that hold the Threading Colors.
	 * @return my_threading_color;
	 */
	public Color[] getThreadingColorArray() {
		return my_threading_color;
	}
	/**
	 * Return the tieup array.
	 * @return my_tieup
	 */
	public boolean[][] getTieupArray() {
		return my_tieup;
	}

	/**
	 * returns the harness that the warp thread is attached to.
	 * @param the_warp The warp thread.
	 * @return The harness that the warp thread is attached to.
	 */
	public int getHarness(int the_warp) {
		return my_threading[the_warp];
	}
	/**
	 * Returns the pedal that should press for a particular weft thread
	 * @param the_weft The weft thread
	 * @return The pedal that should be selected.
	 */
	public int getPedal(int the_weft) {
		return my_treadling[the_weft];
	}
	/**
	 * Returns a boolean value based on the harness and pedal.  If true the warp thread is visible
	 * If false the weft thread is on top.
	 * @param the_pedal
	 * @param the_harness
	 * @return A boolean value based on the harness and the pedal.
	 */
	public boolean getTieup(int the_pedal, int the_harness) {
		return my_tieup[the_harness][the_pedal];
	}
	/**
	 * Returns the color of a warp thread
	 * @param the_index The warp thread.
	 * @return Returns the color of a warp thread.
	 */
	public Color getThreadingColor(int the_index) {
		return my_threading_color[the_index];
	}

	/**
	 * Return the color of a weft thread
	 * @param the_index The weft thread
	 * @return Returns the color of a weft thread.
	 */
	public Color getTreadingColor(int the_index) {
		return my_treadling_color[the_index];
	}
	/**
	 * Sets the harness for a given warp thread.
	 * @param the_harness
	 * @param the_warp
	 */
	public void setHarness(int the_harness, int the_warp) {
		if(the_harness >= HARNESSES || the_harness < 0) {
			System.out.println("Incorrect harness number");
		} else if(the_warp >= SIZE || the_warp < 0) {
			System.out.println("Incorrect warp number");
		} else {
			my_threading[the_warp] = the_harness;
		}
	}
	/**
	 * Sets the pedal for a given weft thread.
	 * @param the_pedal
	 * @param the_weft
	 */
	public void setPedal(int the_pedal, int the_weft) {
		if(the_pedal >= PEDALS || the_pedal < 0) {
			System.out.println("Incorrect pedal number");
		} else if(the_weft >= SIZE || the_weft < 0) {
			System.out.println("Incorrect weft number");
		} else {
			my_treadling[the_weft] = the_pedal;
		}
	}

	/**
	 * Sets a tieup value.  
	 * @param the_pedal
	 * @param the_harness
	 */
	public void setTieup(int the_pedal, int the_harness){
		if(the_pedal >= PEDALS || the_pedal < 0) {
			System.out.println("Incorrect pedal number");
		} else if(the_harness >= HARNESSES || the_harness < 0) {
			System.out.println("Incorrect harness number");
		} else {
			if(my_tieup[the_harness][the_pedal]) {
				my_tieup[the_harness][the_pedal] = false;
			} else {
				my_tieup[the_harness][the_pedal] = true;
			}
		}
	}
	/**
	 * Sets the color of a given warp thread.
	 * @param the_color The color of the thread.
	 * @param the_index The thread to be set.
	 */
	public void setThreadingColor(Color the_color, int the_index) {
		my_threading_color[the_index] = the_color;
	}
	/**
	 * Sets the color of a given weft thread.
	 * @param the_color The color of the thread.
	 * @param the_index The thread to set.
	 */
	public void setTreadingColor(Color the_color, int the_index) {
		my_treadling_color[the_index] = the_color;
	}


}
